feat: stop polling when bridge history item is stale or has an invalid src hash#8479
Open
feat: stop polling when bridge history item is stale or has an invalid src hash#8479
Conversation
cecef86 to
b0227e9
Compare
b0227e9 to
449f0ed
Compare
statusUpdated
addtxhistory
449f0ed to
28dd789
Compare
Member
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
5b420db to
86fb638
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0af4d26. Configure here.
Member
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
Problem
Bridge txHistory persists invalid or premature src tx hashes (specially STX), and pending items could be polled indefinitely, spamming providers and leaving bad state after restarts.
Solution
Subscribe to TransactionController:transactionStatusUpdated instead of transactionFailed / transactionConfirmed, and update history item matching the tx id, action id, hash, batch, or approval
Skips persisting STX src hashes on submit. Set the hash when the tx is confirmed, or backfill from TransactionController as needed
If a transaction is deemed "too old", fetch the status once, then check if the tx has been mined on chain. If The src hash is nonexistent, stop polling and delete the history item to prevent re-polling on the next restart
References
Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4380
Checklist
Note
Medium Risk
Changes bridge tx polling and transaction event handling, including deleting history entries deemed stale/invalid; mistakes could stop status updates prematurely or remove valid history items.
Overview
Stops indefinite bridge-status polling by introducing an age-based cutoff (
maxPendingHistoryItemAgeMsfrom remote feature flags, default 2 days) and deletingtxHistoryentries that appear to have an invalid/unminedsrcTxHash, emitting a newpolling_statusreasoninvalid_transaction_hash.Migrates
BridgeStatusControllerfromtransactionFailed/transactionConfirmedsubscriptions toTransactionController:transactionStatusUpdated, with broader history matching (id/actionId/batchId/hash/approvalTxId), avoids persisting Smart Transaction hashes until finalized, and refactors metrics to reuse a sharedgetPollingStatusUpdatedPropertiespayload (including improvederror_messageformatting).Reviewed by Cursor Bugbot for commit 92fa59a. Bugbot is set up for automated code reviews on this repo. Configure here.